import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import enTranslation from './en/translation.json';
import hindiTranslation from './hindi/translation.json';


let lang = window.localStorage.getItem('i18nextLng');

if (lang === null) {
  lang = 'en';
  window.localStorage.setItem('i18nextLng', 'en');
}

i18next.use(initReactI18next).init({
  lng: lang, // if you're using a language detector, do not define the lng option
  debug: false,
  interpolation: {
    escapeValue: false // react already safes from xss
  },
  resources: {
    en: {
      translation: enTranslation,
    },
    hindi: {
      translation: hindiTranslation,
    },
  },
  // if you see an error like: "Argument of type 'DefaultTFuncReturn' is not assignable to parameter of type xyz"
  // set returnNull to false (and also in the i18next.d.ts options)
  // returnNull: false,
});